#include <stdio.h>
//typedef UINT64 unsigned long long 


//void  doubletostr(double* a, char* str){
void  floattostr(float* a, char my_str[32]){

	long c;
	c= ((long*)a)[0];
	int i;
	for(i=0;i<32;i++){
               my_str[31-i]=(char)(c&1)+'0';
		c>>=1;
	}
	my_str[32] = '\0';
}
void main (int argc, char **argv)
//void main(void)
{
	//char* str = "11000000000101000000000000000000000000000000000000000000000000000000000000";
	float a = 1.00;
	char  str[32] ;
	int i;
	int len ;
	
	//floattostr(&a,str);
	//printf("float is %lf \n", a );
	//printf("float is %s\n", str );

   	FILE * fpw_float = fopen("float.txt", "w");
   	FILE * fpw_bin   = fopen("float_bin.txt", "w");
        len = atoi(argv[1]);
	
	for (i=0;i<=len;i++){
		a=i;
		floattostr(&a,str);
		printf("float is %lf \n", a );
		printf("float is %s\n", str );
		fputs(str,fpw_bin);
		//fputs(a,fpw_float);
		//fprintf(fpw_float,"%f",a);
		fprintf(fpw_float,"%d",i);
		fputs("\n",fpw_bin);
		fputs("\n",fpw_float);
	}
	fclose(fpw_bin);
	fclose(fpw_float);
}
